package com.tool.btn;

import java.awt.*;
import java.awt.event.MouseEvent;

import javax.swing.SwingConstants;

import org.apache.commons.lang.StringUtils;
import org.come.Frame.OptionsJframe;
import org.come.Frame.PetLxJframe;
import org.come.Frame.ZhuFrame;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.FormsManagement;
import org.come.until.Music;
import org.come.until.UserMessUntil;
import org.skill.frame.LXiulianMainFrame;
import org.skill.panel.LxPanel;

import com.tool.tcpimg.UIUtils;

import come.tool.JDialog.TiShiUtil;

public class PetLxBtn extends MoBanBtn {

	private static final long serialVersionUID = 7822149256715030997L;
	private int event;

	private LxPanel panel;

    public PetLxBtn(String iconpath, int type, int event) {
        super(iconpath, type);
        this.event = event;
    }

    public PetLxBtn(String iconpath, int type, String text, int event) {
        super(iconpath, type, UIUtils.COLOR_BTNPUTONG);
        this.setText(text);
        setFont(UIUtils.TEXT_HY88);
        this.event = event;
        setVerticalTextPosition(SwingConstants.CENTER);
        setHorizontalTextPosition(SwingConstants.CENTER);
    }
    public PetLxBtn(String iconpath, int type, String text, int event,String sm) {
    	super(iconpath, type, UIUtils.COLOR_BLACK);
    	this.setText(text);
    	setFont(UIUtils.TEXT_HY88);
    	this.event = event;
    	setVerticalTextPosition(SwingConstants.CENTER);
    	setHorizontalTextPosition(SwingConstants.CENTER);
    }

    public PetLxBtn(String iconpath, int type, String text, int event, LxPanel panel) {
        super(iconpath, type, UIUtils.COLOR_BTNPUTONG);
        this.setText(text);
        setFont(UIUtils.TEXT_HY88);
        this.event = event;
        this.panel = panel;
        setVerticalTextPosition(SwingConstants.CENTER);
        setHorizontalTextPosition(SwingConstants.CENTER);
    }
    public PetLxBtn(String iconpath, int type, String text, int event, LxPanel panel,String sm) {
    	super(iconpath, type, UIUtils.COLOR_BLACK);
    	this.setText(text);
    	setFont(UIUtils.TEXT_HY88);
    	this.event = event;
    	this.panel = panel;
    	setVerticalTextPosition(SwingConstants.CENTER);
    	setHorizontalTextPosition(SwingConstants.CENTER);
    }


	public PetLxBtn(String iconpath, int type, String text, int event, Color foregroundColor) {
		super(iconpath, type, UIUtils.COLOR_BTNPUTONG2);
		this.setText(text);
		setFont(UIUtils.TEXT_HY88);
		this.event = event;
		setVerticalTextPosition(SwingConstants.CENTER);
		setHorizontalTextPosition(SwingConstants.CENTER);
		if (foregroundColor != null) {
			setForeground(foregroundColor);
		}
	}
	@Override
    public void chooseyes() {

    }

    @Override
    public void chooseno() {

    }

    @Override
    public void nochoose(MouseEvent e) {
    	if (event < 5) {
	    	PetLxJframe.getPetLxJframe().getLxPanel().changePanel(event);
	        Music.addyinxiao("开关窗口.mp3");
    	} else {
    		switch (event) {
			case 5:
				 // 获取当前召唤兽信息
				LXiulianMainFrame.getLXiulianMainFrame().getLXiulianMainPanel().panelGetData(UserMessUntil.getChosePetMes());
				FormsManagement.showForm(602);
				break;
			case 6:
				// 洗点
				OptionsJframe.getOptionsJframe().getOptionsJpanel().showBox(TiShiUtil.XiLingXi,
            			UserMessUntil.getChosePetMes().getSid(),
            			"#Y洗点需消耗#R200#Y仙玉，会清空所有灵犀技能返还灵犀点数。#R（已开启的灵犀技能格不需要重新开启）");

				break;
			case 7:
				if (panel != null) {

					String lingxi = panel.getLingxi();
					if (StringUtils.isNotEmpty(lingxi)) {
						// 发送给服务器
		                String save = Agreement.getAgreement().LingXiAgreement("S&"+UserMessUntil.getChosePetMes().getSid() + "&" + panel.getLingxi());
		                // 向服务器发送信息
		                SendMessageUntil.toServer(save);
					} else {
						ZhuFrame.getZhuJpanel().addPrompt2("你还没有点过该类型的任何灵犀技能呢");
						return;
					}
				}
				break;
			case 8: // 单次修炼
				// 发送给服务器
                String xl = Agreement.getAgreement().LingXiAgreement("X&"+UserMessUntil.getChosePetMes().getSid());
                // 向服务器发送信息
                SendMessageUntil.toServer(xl);
				break;
			case 9: // 一键修炼
				// 发送给服务器
                String xl2 = Agreement.getAgreement().LingXiAgreement("Z&"+UserMessUntil.getChosePetMes().getSid());
                // 向服务器发送信息
                SendMessageUntil.toServer(xl2);
				break;
			default:
				break;
			}
    	}
    }
}